//
//  ZRRequestManager.h
//  HelpThePoor
//
//  Created by van7ish on 2016/12/5.
//  Copyright © 2016年 van7ish. All rights reserved.
//

#import <Foundation/Foundation.h>

//typedef void (^SuccessBlock)(id JSON);
//typedef void (^FailureBlock)(NSError *error);

typedef void (^  Success)(id responseObject);     // 成功Block
typedef void (^  Failure)(NSError *error);        // 失败Blcok
typedef void (^  Progress)(NSProgress *  progress); // 上传或者下载进度Block
typedef NSURL *  (^  Destination)(NSURL *targetPath, NSURLResponse *response); //返回URL的Block
typedef void (^  DownLoadSuccess)(NSURLResponse * response, NSURL * filePath); // 下载成功的Blcok

@interface ZRRequestManager : NSObject

/**
 *  超时时间(默认20秒)
 */
@property (nonatomic, assign) NSTimeInterval timeoutInterval;

/**
 *  可接受的响应内容类型
 */
@property (nonatomic, copy) NSSet <NSString *> *acceptableContentTypes;


/**
 *  封装的GET请求
 *
 *  @param URLString  请求的链接
 *  @param parameters 请求的参数
 *  @param success    请求成功回调
 *  @param failure    请求失败回调
 */
+ (void)GET:(NSString *)URLString parameters:(NSDictionary *)parameters success:(Success)success failure:(Failure)failure;

/**
 *  封装的POST请求
 *
 *  @param URLString  请求的链接
 *  @param parameters 请求的参数
 *  @param success    请求成功回调
 *  @param failure    请求失败回调
 */
+ (void)POST:(NSString *)URLString parameters:(NSDictionary *)parameters success:(Success)success failure:(Failure)failure;

/**
 *  下载
 *
 *  @param URLString       请求的链接
 *  @param progress        进度的回调
 *  @param destination     返回URL的回调
 *  @param downLoadSuccess 发送成功的回调
 *  @param failure         发送失败的回调
 */
+ (NSURLSessionDownloadTask *)downLoadWithURL:(NSString *)URLString progress:(Progress)progress destination:(Destination)destination downLoadSuccess:(DownLoadSuccess)downLoadSuccess failure:(Failure)failure;

+ (void)downLoadWithUrlString:(NSString *)urlString;



@end
